<?php
	require_once("curl.php");
	//$wallpapers = get("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=d72f4291ca0015e3c71ddd64af5b154f&group_id=65811237@N00");

	$params = array
	(
	'api_key'	=> 'd72f4291ca0015e3c71ddd64af5b154f',
	'method'	=> 'flickr.photos.search',
	'group_id'	=> '65811237@N00',
	'format'	=> 'php_serial',
	'extras'	=> 'original_format',
	);

$encoded_params = array();

foreach ($params as $k => $v){

	$encoded_params[] = urlencode($k).'='.urlencode($v);
}


#
# call the API and decode the response
#

$url = "http://api.flickr.com/services/rest/?".implode('&', $encoded_params);

$rsp = file_get_contents($url);

$rsp_obj = unserialize($rsp);

if ($rsp_obj['stat'] == 'ok')
	{


	$photo_title = $rsp_obj['photos']['photo'][1]['title'];

	$r = rand(0, sizeof($rsp_obj['photos']['photo']));


	while(!$rsp_obj['photos']['photo'][$r]['originalsecret'])
	{
		$r = rand(0, sizeof($rsp_obj['photos']['photo']));

	}

		echo $p['originalsecret'];

	$p = $rsp_obj['photos']['photo'][$r];

	$ur = "http://farm" . $p['farm'] . ".static.flickr.com/" . $p['server'] . "/" .  $p['id'] . "_" .  $p['originalsecret'] . "_o." . $p['originalformat'];
	 header("Content-Type: image/" . $p['originalformat']);

	echo get($ur);
}

	else
	{
		echo (":(");
	}

?>
